home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
pnl006.zip
/
BINARY.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-03-17
|
659b
|
26 lines
Function binary(look : integer) :integer;{Find binary way}
{Look is the variable you're looking for}
var
temp, {The number}
b,mid,z, {Front and end}
f:integer; {For next loops}
Begin
b:=1; {Set variables}
z:=count;
temp:=-1;
repeat
mid:=(b+z) div 2; {Middle}
if a[mid].id=look then temp:=a[mid].inv
else if a[mid].id<look then b:=mid+1
else if a[mid].id>look then z:=mid-1;
until (temp>-1) or (b>z);
binary:=temp;
End;